real beta=-0.5;
func g= (2*(pi^2)+ beta )*sin(pi*x)*cos(pi*y);
func sol = sin(pi*x)*cos(pi*y);
int nbh=5;
real[int] errL2(nbh);
real[int] errH1(nbh);
real[int] lesh(nbh);

ofstream pfile("resultTest.txt");

border a(t=-1,1){x=t; y=-1;label=1;}; 
border b(t=-1,1){x=1; y=t;label=2;}; 
border c(t=0,1){x=1-2*t; y=1;label=3;}; 
border d(t=0,1){x=-1; y=1-2*t;label=4;}; 
int i=1;
real h;
real n;

for (int i=1;i<=nbh;i++) 
{
n=2*5*i;

mesh Domaine=buildmesh (a(n)+b(n)+c(n)+d(n));
//plot(Domaine,wait=1);


	fespace Espace(Domaine,P2);
	Espace u,v;

	solve Probleme(u,v) = int2d(Domaine)(dx(u)*dx(v)+dy(u)*dy(v)
				+ beta*u*v )
				-int2d(Domaine)(g*v)
				+ on(2,4,u=0);
	
	//plot(u,wait=1,fill=1,nbiso=100);		

	Espace erreur = sol - u;
	errL2[i-1]=(sqrt(int2d(Domaine) (erreur^2)));
	errH1[i-1]=(sqrt(int2d(Domaine) ((erreur^2)+(dx(erreur))^2+(dy(erreur))^2)));

	Espace h=hTriangle;


	lesh[i-1] =(h[].max);


	pfile << (lesh[i-1]) <<" "<< (errH1[i-1])<<" "<< (errL2[i-1]) << endl;
	


}


